package com.google.code.tutorials.java.spring.data.jpa.domain;

import javax.persistence.*;
import org.springframework.data.jpa.domain.AbstractPersistable;

/**
 * Entity implementation class for Entity: User
 * 
 */
@Entity
@NamedQuery(name = "User.findByTheUsersName", query = "from User u where u.username = ?1")
public class User extends AbstractPersistable<Long> {
	private static final long serialVersionUID = 1L;
	
	@Column(unique = true)
	private String username;
	private String firstname;
	private String lastname;

	public User() {
		this(null);
	}
	
	public User(Long id){
		this.setId(id);
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getFirstname() {
		return firstname;
	}

	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}

	public String getLastname() {
		return lastname;
	}

	public void setLastname(String lastname) {
		this.lastname = lastname;
	}

	@Override
	public String toString() {
		return "User [username=" + username + ", firstname=" + firstname + ", lastname=" + lastname + ", getId()=" + getId() + "]";
	}
}
